import request from '@/utils/request'
import request2 from '@/utils/request2'
export function sendCode(params) {
  return request2({
    url: '/znuplod/sendCode',
    method: 'get',
    params
  })
}
export function checkCode(params) {
  return request2({
    url: '/znuplod/tokenCode', 
    method: 'get',
    params
  })
}
export function getList(params) {
  return request({
    url: '/table/list',
    method: 'get',
    params
  })
}
export function getCamera(data,page,size) {
  return request({
    url: '/ws/common/find/zn_camera',
    method: 'post',
    data: {
      filter: data,
      page: page,
      pageSize: size
    }
  })
}
export function addCamera(data) {
  return request({
    url: '/ws/common/insertOne/zn_camera',
    method: 'post',
    data: data
  })
}
export function getCommunityAll() {
  return request({
    url: '/ws/common/find/zn_communityAll',
    method: 'post',
    data: {
      filter: {

      }
    }
  })
}
export function getCameraTree() {
  return request({
    url: '/ws/common/find/zn_cameraTree',
    method: 'post',
    data: {
      filter: {

      }
    }
  })
}


export function addCompany(data) {
  return request({
    url: '/ws/common/insertOne/zn_companyList',
    method: 'post',
    data: data
  })
}
export function addCameraTree(data) {
  return request({
    url: '/ws/common/insertOne/zn_cameraTree',
    method: 'post',
    data: data
  })
}

export function findCompany(data) {
  return request({
    url: '/ws/common/find/zn_companyList',
    method: 'post',
    data: data
  })
}
export function editCompany(data) {
  return request({
    url: '/ws/common/updateOne/zn_companyList',
    method: 'post',
    data: data
  })
}
export function addCommunity(data) {
  return request({
    url: '/ws/common/insertOne/zn_companyList',
    method: 'post',
    data: data
  })
}
export function addUserAdmin(data) {
  return request({
    url: '/ws/common/insertOne/zn_login',
    method: 'post',
    data: data
  })
}
export function deleteUserAdmin(data) {
  return request({
    url: '/ws/common/updateOne/zn_login',
    method: 'post',
    data: data
  })
}
export function updateCommunity(data) {
  return request({
    url: '/ws/common/updateOne/zn_communityAll',
    method: 'post',
    data: data
  })
}
export function getUser(data, page, size) {
  data['AuthorizationRelationship.AuthorizationState'] = '通过'
  return request({
    url: '/ws/common/find/zn_user',
    method: 'post',
    data: {
      filter: data,
      page: page,
      pageSize: size,
      projection:{"AuthorizationRelationship.$":1,"username":1,mobile:1,friends:1,role:1,address:1,state:1,PersonnelCode:1,delete:1,fid:1,Description:1,type:1,cardImg:1,cardinfo:1,friends:1,PhotoLists:1,creatPerson:1,header_img:1}
    }
  })
}
export function getUser2(data, page, size) {
  return request({
    url: '/ws/common/find/zn_user',
    method: 'post',
    data: {
      filter: data,
      page: page,
      pageSize: size
    }
  })
}
export function getUserAuth(data, page, size) {
  return request({
    url: '/ws/common/find/zn_user',
    method: 'post',
    data: {
      filter: data,
      page: page,
      pageSize: size,
      projection:{"AuthorizationRelationship.$":1,"username":1,mobile:1,friends:1,role:1,address:1,state:1,PersonnelCode:1,delete:1,fid:1,Description:1,type:1,cardImg:1,cardinfo:1,friends:1,PhotoLists:1,creatPerson:1}
    }
  })
}
export function getLogin(data) {
  return request({
    url: '/ws/common/aggregate/zn_user',
    method: 'post',
    data: data
  })
}
export function getUserCount(data) {
  return request({
    url: '/ws/common/count/zn_user',
    method: 'post',
    data: {
      filter: data
    }
  })
}
export function getCameraCount(data) {
  return request({
    url: '/ws/common/count/zn_Camera',
    method: 'post',
    data: {
      filter: data
    }
  })
}
export function getChuru(data, page, size) {
  return request({
    url: '/ws/common/find/zn_EntryAndExitRecords',
    method: 'post',
    data: {
      filter: data,
      page: page,
      pageSize: size,
      sort:{'dateTime':1}
    }
  })
}
export function getChuruCount(data) {
  return request({
    url: '/ws/common/count/zn_EntryAndExitRecords',
    method: 'post',
    data: {
      filter: data
    }
  })
}
export function updataChuru(data) {
  return request({
    url: '/ws/common/updateOne/zn_EntryAndExitRecords',
    method: 'post',
    data: data
  })
}
export function updataCamera(data) {
  return request({
    url: '/ws/common/updateOne/zn_camera',
    method: 'post',
    data: data
  })
}
export function updateUser(data) {
  return request({
    url: '/ws/common/updateOne/zn_user',
    method: 'post',
    data: data
  })
}
export function addUserMany(data) {
  return request({
    url: '/ws/common/insertMany/zn_user',
    method: 'post',
    data: data
  })
}

export function getUserImgList(data) {
  return request({
    url: '/ws/common/find/zn_userImgList',
    method: 'post',
    data: {
      filter: data
    }
  })
}
export function updateUserImgList(data) {
  return request({
    url: '/ws/common/updateOne/zn_userImgList',
    method: 'post',
    data: data
  })
}
export function addUserImgList(data) {
  return request({
    url: '/ws/common/insertOne/zn_userImgList',
    method: 'post',
    data: data
  })
}
export function getType(data) {
  return request({
    url: '/ws/common/find/zn_Type',
    method: 'post',
    data: {
      filter: data
    }
  })
}
export function updateType(data) {
  return request({
    url: '/ws/common/updateOne/zn_Type',
    method: 'post',
    data: data
  })
}
export function insertType(data) {
  return request({
    url: '/ws/common/insertOne/zn_Type',
    method: 'post',
    data: data
  })
}
export function getAttendanceList(data) {
  return request({
    url: '/ws/common/find/zn_attendanceList',
    method: 'post',
    data: {
      filter: data
    }
  })
}
export function getInformationsList(data, page, size) {
  return request({
    url: '/ws/common/find/zn_forward',
    method: 'post',
    data: {
      filter: data,
      page: page,
      pageSize: size,
      sort:{'receiveTime':1}
    }
  })
}
export function getInformationsCount() {
  return request({
    url: '/ws/common/count/zn_forward',
    method: 'post',
    data: {
      filter: {}
    }
  })
}
export function setAdmin(data) {//设置管理员
  return request2({
    url: '/znsq/authorization/setAdmin',
    method: 'post',
    data:data
  })
}
export function unsetAdmin(data) {//取消管理员
  return request2({
    url: '/znsq/authorization/unsetAdmin',
    method: 'post',
    data: data
  })
}

